package validate

import (
	"github.com/gin-gonic/gin"
	"github.com/thedevsaddam/govalidator"
)

type ChatForm struct {
	Type     string `json:"type,omitempty" validate:"type"`
	ChatID   uint   `json:"chat_id,omitempty" validate:"chat_id"`
	Title    string `json:"title,omitempty" validate:"title"`
	Content  string `json:"content,omitempty" validate:"content"`
	Messages []struct {
		Role    string `json:"role,omitempty"`
		Content string `json:"content"`
	} `json:"messages" validate:"messages"`
}

type GetChatForm struct {
	ChatID uint `json:"chat_id,omitempty" validate:"chat_id"`
}

func ValidateChat(data interface{}, c *gin.Context) map[string][]string {
	rules := govalidator.MapData{
		"messages": []string{"required"},
		"type":     []string{"required"},
	}

	message := govalidator.MapData{
		"messages": []string{"required:Messages is required"},
		"type":     []string{"required:Type is required"},
	}

	return validate(data, rules, message)
}

func ValidateGetChat(data interface{}, c *gin.Context) map[string][]string {
	rules := govalidator.MapData{
		"chat_id": []string{"required"},
	}

	message := govalidator.MapData{
		"chat_id": []string{"required:ChatID is required"},
	}

	return validate(data, rules, message)
}

func ValidateCreateChat(data interface{}, c *gin.Context) map[string][]string {
	rules := govalidator.MapData{
		"title": []string{"required"},
	}

	message := govalidator.MapData{
		"title": []string{"required:Title is required"},
	}

	return validate(data, rules, message)
}
